package demo1;
class Ducks {
    private String name;
    private static String color;

    public static int age;

    public void func() {
        //可以在非静态方法中访问静态成员，但是不能在静态成员中访问非静态成员
        Ducks duck = new Ducks();
        System.out.println(duck.name);
        System.out.println(duck.color);
        System.out.println(duck.age);
    }
    public static void func2() {
        Ducks duck = new Ducks();
        duck.name="666";
        Ducks.age=888;
        Ducks.color="55";
        duck.age=12;
        //Ducks.name="666";//
    }
}
public class Duck {
    public static void main(String[] args) {
        Ducks duck = new Ducks();
        duck.age=18;
        Ducks.age=21;
        duck.age=999;
        duck.func();
    }
}
